<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>服务器登陆</title>
    <script type="text/javascript">
        /**
         * Created by chenyu on 15/12/10.
         */

        function func(command) {
            var xhr = null;
            var xhr2 = null;
            try {
                if (window.XMLHttpRequest) {
                    xhr = new XMLHttpRequest();
                    xhr2 = new XMLHttpRequest();
                }
                else if (window.ActiveXObject) {
                    xhr = new ActiveXObject("Msxml2.Xmlhttp");
                    xhr2 = new ActiveXObject("Msxml2.Xmlhttp");
                }
            }
            catch (err) {
                xhr = new ActiveXObject("Microsoft.Xmlhttp");
                xhr2 = new ActiveXObject("Microsoft.Xmlhttp");
            }


            xhr2.onreadystatechange = function () {
                if (xhr2.readyState == 4 && xhr2.status == 200) {
                    var result = xhr2.responseText;
                    alert("result is:"+result);
                }
            }
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var code = xhr.responseText;
                    var code = code.substr(9);
                    xhr2.open("get", "http://manage.do4u.com.cn:12306/?cmd="+command+"&port=ssh&key="+code);
                    xhr2.send(null);

                }
            }

            xhr.open("get", "http://manage.do4u.com.cn:12306/?cmd=key");
            xhr.send(null);

        }

        function login(){
            func("add");
        }
        function query(){
            func("query");
        }
        function del(){
            func("del");
        }



    </script>
</head>
<body>
<table align="center">
    <tr>
        <th></th>
        <th></th>
        <th></th>
    </tr>
    <tr>
        <td>
            <input type="button" value="登陆" onclick="login()"/>
        </td>
        <td>
            <input type="button" value="查询" onclick="query();"/>
        </td>
        <td>
            <input type="button" value="删除" onclick="del();"/>
        </td>
    </tr>
</table>
</body>
</html>
